package com.fsbm.ctech.maxis.ebpsbackend;

import java.io.*;

import java.util.StringTokenizer;

public class test {
	public static void main(String[] args) {

		BufferedReader br = null;

		try {

			String sCurrentLine;

			br = new BufferedReader(new FileReader("D:/BatchLoadAmdocsReport_20120929_0330_24.csv"));
			FileWriter fstream = new FileWriter("D:/MBatchLoadAmdocsReport_20120929_0330_24.csv");
  			BufferedWriter out = new BufferedWriter(fstream);
			while ((sCurrentLine = br.readLine()) != null) {
				String temp = sCurrentLine;
				StringTokenizer stk = new StringTokenizer(temp,",");
				System.out.println("Token count:"+stk.countTokens() );
				int count=0;

				if(stk.countTokens()==9){
					while(stk.hasMoreElements()){
						String element = (String)stk.nextElement();
						if (count==5){
							out.write("0"+element+",");
						}else{
							out.write(element+",");
						}
						count++;
					}
					out.write("\n");
				}else{
					out.write(sCurrentLine+"\n");
					count++;
				}
			}

			br.close();
			out.close();

		} catch (IOException e) {
			e.printStackTrace();
		} finally {
			try {
				if (br != null)br.close();
			} catch (IOException ex) {
				ex.printStackTrace();
			}
		}

	}}